package com.wayne.testapp.activity;

import android.os.Bundle;
import android.support.v7.widget.AppCompatButton;
import android.util.Log;
import android.view.View;

import com.wayne.testapp.R;
import com.wayne.testapp.api.RosettaApi;

import java.io.IOException;

import butterknife.ButterKnife;
import butterknife.InjectView;
import butterknife.OnClick;
import okhttp3.ResponseBody;
import retrofit2.Call;
import retrofit2.Callback;
import retrofit2.Response;
import retrofit2.Retrofit;

/**
 * Created by wayne on 2016/06/28.
 */
public class TestRetrofitAcitivty extends BaseActivity {
    private static final String TAG = "TestRetrofitAcitivty";
    @InjectView(R.id.bt_request)
    AppCompatButton btRequest;
    @InjectView(R.id.bt_request2)
    AppCompatButton btRequest2;


    @Override
    protected void onCreate(Bundle savedInstanceState) {
        super.onCreate(savedInstanceState);
        setContentView(R.layout.act_test_retrofit);
        ButterKnife.inject(this);


    }

    @OnClick({R.id.bt_request, R.id.bt_request2})
    public void onClick(View view) {
        switch (view.getId()) {
            case R.id.bt_request:
                String base = "http://cbs-test.shenmajr.com/cbsapi/";
                Retrofit retrofit = new Retrofit.Builder()
                        .baseUrl(base).build();
                RosettaApi rosettaApi = retrofit.create(RosettaApi.class);
//                Call<ResponseBody> call = rosettaApi.getSms("15000983434");
//
//
//                call.enqueue(new Callback<ResponseBody>() {
//                    @Override
//                    public void onResponse(Call<ResponseBody> call, Response<ResponseBody> response) {
//                        Log.i(TAG, response.code() + "");
//                        try {
//                            Log.i(TAG, new String(response.body().bytes()));
//                        } catch (IOException e) {
//                            e.printStackTrace();
//                        }
//                    }
//
//                    @Override
//                    public void onFailure(Call<ResponseBody> call, Throwable t) {
//                        Log.i(TAG, t.getMessage());
//                    }
//                });
                break;
            case R.id.bt_request2:
                break;
        }
    }
}
